extends Node2D


@onready var body: Line2D = $body
var redius: int = 10


func _ready() -> void:
	for i in range(0,body.points.size()):
		body.points[i] = Vector2(i*2,200.0)



func _process(delta: float) -> void:
	var pts = body.points
	
	var move = Vector2(
		Input.get_action_strength("move_right")-Input.get_action_strength("move_left"),
		Input.get_action_strength("move_down")-Input.get_action_strength("move_up")
	)
	
	
	if move != Vector2.ZERO:
		pts[0] += move*200*delta
	
	for i in range(1,pts.size()):
		pts[i] = pts[i-1] + (pts[i] - pts[i-1]).limit_length(redius)
		body.points = pts
	
	
	queue_redraw()
	
	
